/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved
*
*  This file is part of the GroupMe! Project. You can utilize
*  software of the GroupMe! project under the terms of the 
*  GNU Lesser General Public License as published by the
*  Free Software Foundation in version 2.1.
* 
*  The GNU Lesser General Public License can be found at:
*  http://www.gnu.org/licenses/lgpl.html
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.utils.sql;

import java.sql.ResultSet;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.jdbc.object.MappingSqlQuery;

/**
 * 
 * This class provides a SQL Query to get a single string from a single table for an ID.
 * 
 * @author  Mischa Frank <a href="mailto:code@planetfrank.net">code@planetfrank.net</a> 
 * 
 * @version 1.0, created on 09.05.2007 
 *
 */

public class GetStringFromTableWhereIDQuery extends MappingSqlQuery {
	private String columnName;
	public GetStringFromTableWhereIDQuery(DataSource ds, String string, String table, String id) {
        super(ds, "SELECT " + string + " from " + table + " where id = " + id);
        this.columnName = string;
        compile();
    }

    protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
        return rs.getString(columnName); 
    }
}